package cn.iocoder.yudao.module.crossborder.finance.api;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.crossborder.finance.api.dto.SettlementDTO;
import cn.iocoder.yudao.module.crossborder.finance.api.dto.ExchangeRateDTO;
import cn.iocoder.yudao.module.crossborder.finance.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;

/**
 * 财务结算管理 API 接口
 *
 * @author LHL
 */
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿：fallbackFactory =
@Tag(name = "RPC 服务 - 财务结算管理")
public interface FinanceApi {

    String PREFIX = ApiConstants.PREFIX + "/finance";

    @GetMapping(PREFIX + "/settlement/get")
    @Operation(summary = "获得财务结算记录")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    CommonResult<SettlementDTO> getSettlement(@RequestParam("id") @NotNull Long id);

    @GetMapping(PREFIX + "/settlement/list")
    @Operation(summary = "获得财务结算记录列表")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    CommonResult<List<SettlementDTO>> getSettlementList(@RequestParam("ids") @NotNull List<Long> ids);

    @PostMapping(PREFIX + "/settlement/create")
    @Operation(summary = "创建财务结算记录")
    CommonResult<Long> createSettlement(@RequestBody @Valid SettlementDTO settlement);

    @GetMapping(PREFIX + "/exchange-rate/get")
    @Operation(summary = "获取汇率")
    @Parameter(name = "fromCurrency", description = "源货币", required = true, example = "USD")
    @Parameter(name = "toCurrency", description = "目标货币", required = true, example = "CNY")
    CommonResult<ExchangeRateDTO> getExchangeRate(@RequestParam("fromCurrency") @NotNull String fromCurrency,
                                                  @RequestParam("toCurrency") @NotNull String toCurrency);

    @PostMapping(PREFIX + "/fee/calculate")
    @Operation(summary = "计算费用")
    @Parameter(name = "orderId", description = "订单编号", required = true, example = "1024")
    @Parameter(name = "feeType", description = "费用类型", required = true, example = "1")
    CommonResult<BigDecimal> calculateFee(@RequestParam("orderId") @NotNull Long orderId,
                                         @RequestParam("feeType") @NotNull Integer feeType);

    @PostMapping(PREFIX + "/settlement/process")
    @Operation(summary = "处理结算")
    @Parameter(name = "orderId", description = "订单编号", required = true, example = "1024")
    CommonResult<Boolean> processSettlement(@RequestParam("orderId") @NotNull Long orderId);

}
